package com.ymttest.database.sqlwapper.shenqisettlement;

import java.util.HashMap;
import java.util.List;

import com.ymt.database.SqlManager;
import com.ymttest.database.model.shenqisettlement.ProxyFissionCommisionRate;

public class ProxyFissionCommisionRateWrapper {

	SqlManager manager;

	public ProxyFissionCommisionRateWrapper() {
		manager = new SqlManager("shenqisettlement");
	}

	@SuppressWarnings("unchecked")
	public ProxyFissionCommisionRate selectByPrimaryKey(long id) {

		ProxyFissionCommisionRate proxyFissionCommisionRate = new ProxyFissionCommisionRate();
		List<ProxyFissionCommisionRate> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.shenqisettlement.ProxyFissionCommisionRateMapper.selectByPrimaryKey",
						id);
		manager.commit();

		if (result.size() > 0) {
			proxyFissionCommisionRate = result.get(0);
		}

		return proxyFissionCommisionRate;
	}
	
	@SuppressWarnings("unchecked")
	public List<ProxyFissionCommisionRate> selectByMerchantIdAndConfigId(Long merchantId, Long configId) {

		HashMap<String, Long> map = new HashMap<>();
		
		map.put("merchant_id", merchantId);
		map.put("proxy_fission_config_id", configId);
		
		List<ProxyFissionCommisionRate> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.shenqisettlement.ProxyFissionCommisionRateMapper.selectByMerchantIdAndConfigId",
						map);
		manager.commit();

		if (result.size() > 0) {
			return result;
		} else {
			return null;
		}
	}
	
	@SuppressWarnings("unchecked")
	public ProxyFissionCommisionRate selectByLevelAndConfigId(Long level, Long configId) {

		ProxyFissionCommisionRate proxyFissionCommisionRate = new ProxyFissionCommisionRate();
		HashMap<String, Long> map = new HashMap<>();
		
		map.put("proxy_level_index", level);
		map.put("proxy_fission_config_id", configId);
		
		List<ProxyFissionCommisionRate> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.shenqisettlement.ProxyFissionCommisionRateMapper.selectByLevelAndConfigId",
						map);
		manager.commit();

		if (result.size() > 0) {
			proxyFissionCommisionRate = result.get(0);
		} 
		
		return proxyFissionCommisionRate;
	}
	
	public static void main(String[] args) {
		
		ProxyFissionCommisionRateWrapper wrapper = new ProxyFissionCommisionRateWrapper();
		
		System.out.println(wrapper.selectByMerchantIdAndConfigId(50055221234L, 3L).get(0).getProxy_level_label());
	}
}
